package CutLoad.mc
{
	import CutLoad.Base;
	import CutLoad.components.container.CScrollV;
	import CutLoad.components.container.ContainerV;

	/**
	 * 显示多行文字列表并且有翻页组件    注：该类把mcList与PageBtnsSome进行了组合    并加上了垂直滚动条
	 * @author smallerbird mail:smallerbird@gmail.com  site:www.mkigm.com QQ群:49983196
	 * 
	 */	
	public class mcListAndPageBtn extends Base
	{
		//CScrollV容器的目标
		private var containerList:ContainerV
		//滚动容器
		private var container:CScrollV
		private var myList:mcList;
		private var pageBtns:PageBtnsSome
		public function mcListAndPageBtn(
			w:Number,
			h:Number,
			//
			classItem:Class,
			funClick:Function,
			funItemOther:Function,
			//
			classBtnPageUp:Function,
			classBtnPageDown:Function,
			classMcBtn:Function,
			pageCount:Number,
			funPageChang:Function,
			currentPage:Number=1,
			showPageBtnNum:Number=3,
			xspace:Number=3,
			//
			offsetSpeed:Number=0.3,
			isShowUpDownBtn:Boolean=true,
			numSeed:Number=2,
			isChangBody:Boolean=true
		)
		{
			//初始化，并它们组合起来
			containerList=ContainerV.getSimple();
			myList=new mcList(
				classItem,
				funClick,
				funItemOther
			);
			pageBtns=new PageBtnsSome(
				classBtnPageUp,
				classBtnPageDown,
				pageCount,
				funPageChang,
				classMcBtn,
				currentPage,
				showPageBtnNum,
				xspace
				);
		    containerList.appendSome([myList,pageBtns]);
			container=new CScrollV(containerList,
				w,
				h,
				offsetSpeed,
				isShowUpDownBtn,
				2,
				isChangBody);
			
			this.addChild(container);
		}
		/**
		 * 清空所有 
		 * 
		 */		
		public function clearAll():void{
			myList.clearAll();
			pageBtns.visible=false;
		}
		/**
		 * 更新数据 
		 * @param data 详见  mcList.update说明
		 * @param pageCount 总页数
		 * @param currentPage 当前页
		 * 
		 */		
		public function update(data:Array,pageCount:Number,currentPage:Number):void{
			myList.update(data);
			pageBtns.reset(pageCount,currentPage);
			pageBtns.visible=true;
			containerList.setTakeWH();
			container.refresh();
		}
		/**
		 * 设置内部列表组件点击时的方法和翻页组件 翻页时调用的额外方法，详见：PageBtnsSome.setFunPageChang说明   和  PageBtns.setFunPageChang说明
		 * @param funListClick
		 * @param funPageChang
		 * @return 
		 * 
		 */		
		public function setFunSomeThing(
			funListClick:Function=null,
			funPageChang:Function=null
		):void{
			if(funListClick!=null){
				myList.setFunClick(funListClick);
			}
			if(funPageChang!=null){
				pageBtns.setFunPageChang(funPageChang);
			}
		}
	}
}